Const CAM_PROJ_NONE:Byte					= 0
Const CAM_PROJ_PERSPECTIVE:Byte		= 1
Const CAM_PROJ_ORTHOGRAPHIC:Byte	= 2

Rem
bbdoc: Klasse zur Verwaltung von normalen und FPS Kameras
endrem 
Type TCamera Extends TEntity
	Field min_zoom:Float
	Field max_zoom:Float
	Field ortho:Byte
	
	Function Create:TCamera(parent:TEntity = Null)
		Local cam:TCamera = Null
		
		If irr_device <> Null
			Local pnode:ISceneNode = Null
			If parent <> Null Then pnode = parent.node
			
			cam = New TCamera
			cam.node			= irr_scene.addCameraSceneNode(pnode)
			cam.min_zoom	= 0.41
			cam.max_zoom	= 100.0
			cam.ortho			= False
		End If
		
		Return cam
	End Function
	
	Function CreateFPS:TCamera(parent:TEntity = Null)
		Local cam:TCamera = Null
		
		If irr_device <> Null
			Local node:ISceneNode = Null
			If parent <> Null Then node = parent.node
			
			cam = New TCamera
			cam.node = irr_scene.addCameraSceneNodeFPS(node, 100, 0.05)
			cam.min_zoom	= 0.41
			cam.max_zoom	= 100.0
			cam.ortho			= False
		End If
		
		Return cam
	End Function
	
	Method SetZoom(zoom:Float = 1.0)
		If zoom < Self.min_zoom Then zoom = Self.min_zoom
		If zoom > Self.max_zoom Then zoom = Self.max_zoom
		
		ICameraSceneNode(Self.node).setFOV(Pi/2.5/zoom)
	End Method
	
	Method ProjMode(mode:Byte = CAM_PROJ_PERSPECTIVE)
		Select mode
			Case CAM_PROJ_NONE
				ICameraSceneNode(Self.node).setVisible(False)
				
			Case CAM_PROJ_PERSPECTIVE
				Local pm:Matrix4 = ICameraSceneNode(Self.node).getProjectionMatrix()
				ICameraSceneNode(Self.node).setVisible(True)
				ICameraSceneNode(Self.node).setprojectionmatrix(pm, False)
				
			Case CAM_PROJ_PERSPECTIVE
				Local pm:Matrix4 = ICameraSceneNode(Self.node).getProjectionMatrix()
				ICameraSceneNode(Self.node).setVisible(True)
				ICameraSceneNode(Self.node).setprojectionmatrix(pm, True)
		End Select
	End Method
	
	
	Method Delete()
		
	End Method
End Type



Rem
bbdoc: Erzeugt eine neue Kamera
endrem
Function CreateCamera:TCamera(parent:TEntity = Null)
	Return TCamera.Create(parent)
End Function


Rem
bbdoc: Erzeugt eine FPS Kamera
about: Eine FPS (First Person Shooter) Kamera kann direkt mittels der Maus und der Pfeiltasten gesteuert werden
endrem
Function CreateFPSCamera:TCamera(parent:TEntity = Null)
	Return TCamera.CreateFPS(parent)
End Function

Rem
bbdoc: Setzt den Zoom-Wert der Kamera
endrem
Function CameraZoom(cam:TCamera, zoom:Float = 1.0)
	cam.SetZoom(zoom)
End Function

Rem
bbdoc: Setzt die Art der Kamera
about: CAM_PROJ_NONE versteckt die Kamera, CAM_PROJ_PERSPECTIVE setzt die Kamera in den normalen perspektivischen Modus (Default) und CAM_PROJ_ORTHOGRAPHIC setzt die Kamera in den orthografischen Modus. Bei letzterem werden keine Tiefenverzerrungen 
gerendert.
endrem
Function CameraProjMode(cam:TCamera, mode:Byte = CAM_PROJ_PERSPECTIVE)
	cam.ProjMode(mode)
End Function